import java.io.*;
import java.util.*;

/*
 ID: ning yusui
 LANG: JAVA
 TASK: lamps
 */

public class lamps {


    public static final int ON = 1;
    public static final int OFF = 0;
    public static final int BUTTON_COUNT = 4;

    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(new File("lamps.in"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
                "lamps.out")));
        int n = in.nextInt();
        int c = in.nextInt();
        int[] state = read(in, n);
        List<int[]> result = search(n, c, state);
        sort(result);
        output(out, result);
    }

    private static void output(PrintWriter out, List<int[]> result) {
        if (result.isEmpty()) {
            out.println("IMPOSSIBLE");
        } else {
            for (int[] r : result) {
                for (int i = 1; i < r.length; i++) {
                    out.print(r[i]);
                }
                out.println();
            }
        }
        out.flush();
        out.close();
    }

    private static void sort(List<int[]> result) {
        Collections.sort(result, new Comparator<int[]>() {
            public int compare(int[] o1, int[] o2) {
                for (int i = 1; i < o1.length; i++) {
                    if (o1[i] != o2[i]) {
                        return o1[i] - o2[i];
                    }
                }
                return 0;
            }
        });
    }

    private static List<int[]> search(int n, int c, int[] state) {
        List<int[]> result = new ArrayList<int[]>();
        for (int opSet = 0; opSet < (1 << BUTTON_COUNT); opSet++) {
            int ones = calcOnes(opSet);
            boolean maybe = ones <= c && (c - ones) % 2 == 0;
            if (maybe) {
                int[] start = createStartState(n);
                opAllButtons(opSet, start);
                boolean eq = check(state, start);
                if (eq) {
                    result.add(start);
                }
            }
        }
        return result;
    }

    private static boolean check(int[] state, int[] start) {
        boolean eq = true;
        for (int i = 1; i < start.length; i++) {
            if (state[i] != -1 && start[i] != state[i]) {
                eq = false;
                break;
            }
        }
        return eq;
    }

    private static void opAllButtons(int opSet, int[] start) {
        for (int op = 0; op < BUTTON_COUNT; op++) {
            if (((1 << op) & opSet) > 0) {
                opButton(op, start);
            }
        }
    }

    private static int calcOnes(int opSet) {
        int ones = 0;
        for (int j = 0; j < BUTTON_COUNT; j++) {
            if ((opSet & (1 << j)) > 0) {
                ones++;
            }
        }
        return ones;
    }

    private static void opButton(int op, int[] start) {
        if (op == 0) {
            for (int i = 1; i < start.length; i++) {
                start[i] = 1 - start[i];
            }
        }
        if (op == 1) {
            for (int i = 1; i < start.length; i += 2) {
                start[i] = 1 - start[i];
            }
        }
        if (op == 2) {
            for (int i = 2; i < start.length; i += 2) {
                start[i] = 1 - start[i];
            }
        }
        if (op == 3) {
            for (int i = 1; i < start.length; i += 3) {
                start[i] = 1 - start[i];
            }
        }
    }

    private static int[] createStartState(int n) {
        int[] start = new int[n + 1];
        for (int index = 1; index < start.length; index++) {
            start[index] = ON;
        }
        return start;
    }

    private static int[] read(Scanner in, int n) {
        int[] state = new int[n + 1];
        for (int i = 1; i < state.length; i++) {
            state[i] = -1;
        }
        while (true) {
            int t = in.nextInt();
            if (t == -1) {
                break;
            } else {
                state[t] = ON;
            }
        }
        while (true) {
            int t = in.nextInt();
            if (t == -1) {
                break;
            } else {
                state[t] = OFF;
            }
        }
        return state;
    }
}
